package com.ruoyi.ky450.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ky450.mapper.TargetCategoryMapper;
import com.ruoyi.ky450.domain.TargetCategory;
import com.ruoyi.ky450.service.ITargetCategoryService;

/**
 * 目标类别Service业务层处理
 *
 * @author ruoyi
 * @date 2025-01-16
 */
@Service
public class TargetCategoryServiceImpl extends ServiceImpl<TargetCategoryMapper, TargetCategory> implements ITargetCategoryService
{
    @Autowired
    private TargetCategoryMapper targetCategoryMapper;

    /**
     * 查询目标类别
     *
     * @param id 目标类别主键
     * @return 目标类别
     */
    @Override
    public TargetCategory selectTargetCategoryById(Long id)
    {
        return targetCategoryMapper.selectTargetCategoryById(id);
    }

    /**
     * 查询目标类别列表
     *
     * @param targetCategory 目标类别
     * @return 目标类别
     */
    @Override
    public List<TargetCategory> selectTargetCategoryList(TargetCategory targetCategory)
    {
        return targetCategoryMapper.selectTargetCategoryList(targetCategory);
    }

    /**
     * 新增目标类别
     *
     * @param targetCategory 目标类别
     * @return 结果
     */
    @Override
    public int insertTargetCategory(TargetCategory targetCategory)
    {
        targetCategory.setCreateTime(DateUtils.getNowDate());
        return targetCategoryMapper.insert(targetCategory);
    }

    /**
     * 修改目标类别
     *
     * @param targetCategory 目标类别
     * @return 结果
     */
    @Override
    public int updateTargetCategory(TargetCategory targetCategory)
    {
        targetCategory.setUpdateTime(DateUtils.getNowDate());
        return targetCategoryMapper.updateTargetCategory(targetCategory);
    }

    /**
     * 批量删除目标类别
     *
     * @param ids 需要删除的目标类别主键
     * @return 结果
     */
    @Override
    public int deleteTargetCategoryByIds(Integer[] ids)
    {
        return targetCategoryMapper.deleteTargetCategoryByIds(ids);
    }

    /**
     * 删除目标类别信息
     *
     * @param id 目标类别主键
     * @return 结果
     */
    @Override
    public int deleteTargetCategoryById(Long id)
    {
        return targetCategoryMapper.deleteTargetCategoryById(id);
    }

    @Override
    public String getNameById(Long id) {
        TargetCategory bean = getById(id);
        if(bean!=null){
            return bean.getCategoryName();
        }
        return null;
    }

}
